import plotly.graph_objs as go
import pandas as pd
from plotly.offline import iplot
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv")
df.head(5)
| Date | AAPL.Open | AAPL.High | AAPL.Low | AAPL.Close | AAPL.Volume | AAPL.Adjusted | dn | mavg | up | direction | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2015-02-17 | 127.489998 | 128.880005 | 126.919998 | 127.830002 | 63152400 | 122.905254 | 106.741052 | 117.927667 | 129.114281 | Increasing |
| 1 | 2015-02-18 | 127.629997 | 128.779999 | 127.449997 | 128.720001 | 44891700 | 123.760965 | 107.842423 | 118.940333 | 130.038244 | Increasing |
| 2 | 2015-02-19 | 128.479996 | 129.029999 | 128.330002 | 128.449997 | 37362400 | 123.501363 | 108.894245 | 119.889167 | 130.884089 | Decreasing |
| 3 | 2015-02-20 | 128.619995 | 129.500000 | 128.050003 | 129.500000 | 48948400 | 124.510914 | 109.785449 | 120.763500 | 131.741551 | Increasing |
| 4 | 2015-02-23 | 130.020004 | 133.000000 | 129.660004 | 133.000000 | 70974100 | 127.876074 | 110.372516 | 121.720167 | 133.067817 | Increasing |
data = [go.Scatter(
x=df.Date,
y=df['AAPL.Close'])]
iplot(data)
tesla = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/tesla-stock-price.csv")
tesla.head(5)
| date | close | volume | open | high | low | |
|---|---|---|---|---|---|---|
| 0 | 11:34 | 270.49 | 4,787,699 | 264.50 | 273.88 | 262.2400 |
| 1 | 2018/10/15 | 259.59 | 6189026.0000 | 259.06 | 263.28 | 254.5367 |
| 2 | 2018/10/12 | 258.78 | 7189257.0000 | 261.00 | 261.99 | 252.0100 |
| 3 | 2018/10/11 | 252.23 | 8128184.0000 | 257.53 | 262.25 | 249.0300 |
| 4 | 2018/10/10 | 256.88 | 12781560.0000 | 264.61 | 265.51 | 247.7700 |
trace_one = go.Scatter(
x=tesla.date,
y=tesla['high'],
name= "Tesla High",
line = dict(color='#17BECF'),
opacity = 0.8)
trace_two = go.Scatter(
x=tesla.date,
y=tesla['low'],
name= "Tesla Low",
line = dict(color='#7F7F7F'),
opacity = 0.8)
data = [trace_one, trace_two]
layout = dict(
title = 'Tesla Stock Price - High vs Low')
fig = dict(data=data, layout=layout)
iplot(fig, filename = 'Tesla Stock Comparison')